{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import torch"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "# 验证了连续构造的计算图仍旧可以进行梯度下降。\n",
    "a = torch.tensor([10.],requires_grad=True)\n",
    "b = torch.tensor([20.],requires_grad=True)\n",
    "c = torch.tensor([30.],requires_grad=True)\n",
    "d = torch.tensor([40.],requires_grad=True)\n",
    "y = 10*a + b**2\n",
    "y += 2*a+3*b+10*c + d**2\n",
    "loss = y - torch.tensor(100)\n",
    "loss.backward()\n",
    "print(a.grad,b.grad,c.grad,d.grad)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "tensor([12.]) tensor([43.]) tensor([10.]) tensor([80.])\n"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "loss.backward()\n",
    "print(loss.grad,a.grad,b.grad)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "def f(a,parm,*b,**c):\n",
    "    print(a)\n",
    "    print(b)\n",
    "    print(c)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "d = {\n",
    "    \"k\":12,\n",
    "    \"l\":13\n",
    "}\n",
    "f(1,parm=d,e=10,c=d)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "import numpy as np\n",
    "a = np.array([[1,2],[3,4]])\n",
    "b=a[1]\n",
    "b[1]=10000"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "a"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "a = {}\n",
    "b = 100\n",
    "b = a.get(\"hello\")\n",
    "print(a.)\n",
    "print(b)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "\n"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [],
   "outputs": [],
   "metadata": {}
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.8.10 64-bit ('pysyft': virtualenvwrapper)"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "orig_nbformat": 2,
  "interpreter": {
   "hash": "54f0cca124f38538f0af9da5035feb8330e039430efda7f6532c7bec2bbfbd8a"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}